Code Description
Our implementation of the DWT based compression algorithm was carried out
in C++ in the Linux environment. We used an Object Oriented approach to
the problem, a summary of which is given in this page.
We constructed the following objects for our implementation:
-
Signal: This object represents a 2-D signal.
-
Subbands: This object is a collection of signals and represents
different subbands of the signal.
-
Filter: This object represents a 2-D FIR filter.
-
Bank: This object represents a Filter Bank. It can either be an
Analysis Bank or a Synthesis Bank.
The Signal Object
The signal object represents a 2-D signal. It represents the input
image as an array of float data. Member functions include:
-
Constructors, Destructors, Initializations, Deletions, Data setting &
retreival functions.
-
File I/O functions, including functions for saving unquantized/quantized
signal & Run-Length coded files
-
Downsampling & Upsampling by M
-
Transpositions & Flips
-
Extension functions include zero, periodic & symmetric (half-point
& whole-point) extension.
-
Row & Column manipulations
-
2-D delays & advances
-
Elementary math functions: sum of elements, sum of squares, minimum value,
maximum value, Arithematic Mean, Standard Deviation.
-
Quantization functions which also calculate entropy of quantized signal
-
Overloaded Operators (elementwise): = + - *
The Subbands Object
The subbands object represents the subbands of a decomposed 2-D
signal. It is a collection of signal objects. Member functions coded
include:
-
Constructors, Destructors, Initializations, Data setting & retreival
functions
-
File I/O functions, including functions for saving unquantized/quantized
subbands & Run-Length coded files
-
Quantization functions which also calculate entropy of quantized subbands
-
Overloaded Operators (elementwise): =
The Filter Object
The filter object represents a 2-D FIR filter implemented in the
form of a non-separable Filter (2-D convolution). A signal object
represents the impulse response of a filter object. Member functions
include:
-
Constructors, Destructors, Initializations, Data setting & retreival
functions
-
Filtering options include: Simple filtering (output size larger than input
size), Filtering with zero/periodic/symmetric extensions (output size same
as input size).
-
Downsampling after and Upsampling before can be performed in the same step
as filtering. These specialized functions use the Polyphase form of the
multirate filters to achieve computational efficiency.
The Bank Object
A bank object is a collection of filter object (and associated
"wiring" information) that constitute a Filter Bank. It can either be an
analysis filter bank or a synthesis bank. The structure of the bank object
is such that it can allow implementation of any arbitrary configuration
of filters. Member Functions include:
-
Constructors, Destructors, Initializations, Deletions, Data setting &
retreival functions
-
Specialized Initialization functions which initialize the bank object
as a DWT/IDWT bank.
-
Functions to allow interconnection of filters in arbitrary ways to allow
other forms of filter banks as well. This is particularly useful in case
the code is extended to implement the Wavelet Packet Transform as well.
The Main Program
The main program initializes the input signal and the
banks and inputs the input signal to the bank. The
output of the bank are subbands of the decomposed signal
representing its 2-D DWT. A Rate Constraint is taken from the user
and the program enters into a recursive procedure to determine the optimal
bit allocations (according to the bit allocation algorithm based on Rate
Distortion Theory for (near) gaussian distributed signals [Strang]). The
subbands are then quantized, their entropies calculated and finally
written to disk. The gzip utility is then called to perform the
LZ coding step.
The quantized subbands are then used to reconstruct the image.
Entropy, PSNR & time consumed are displayed..